#

| Chapter 35 You Can't Quite Call This Editing |

## 35.5 Remove Mail/News Headers with behead

When you're saving or re-sending a news article or mail message (1.33), you might want to the remove header lines (Subject:, Received:, and so on). This little script will handle standard input, one or many files. It writes to standard output. Here are a few examples:

- With saved messages, at a shell prompt:

  >     % behead msg* | mail -s "Did you see these?" fredf

- To save an article, from a pipe, without a header, from a program (here, the old readnews) that can't cut off headers itself:

  >     What now? [ynq] s- | behead > filename

Here's the script, adapted a little from the original by Arthur David Olson:

>     #! /bin/sh
>     case $# in
>     0)  exec sed '1,/^$/d' ;;
>     *)  for i
>         do sed '1,/^$/d' "$i"
>         done
>         ;;
>     esac

The script relies on the fact that mail messages use a blank line to separate the header from the body of the message. As a result, the script simply deletes the text from the beginning up to the first blank line.

- JP

35.4 recomment: Clean Up Program Comment Blocks |  | 35.6 Low-Level File Butchery with dd